
clc
clear all
close all

load('Parameters.mat');
BGP_allocations;


 while abs(g(ii) -g(ii-1))>tolgT

gg=g(ii);

     
  %%Use definition of T = \sum A to update growth rate of T sector
     
     for i=1:M
         for j=1:M
Delta_eps(i,j) = (eps(i,j)/(eps(i,j)+g(ii)))*(1+g(ii))*lam(j)*(P(j)*H_r(j)/((Yw)))^betar;
       end
     end
     
[a,b]=eig(Delta_eps);
[c,vv]=max(diag(b));

T=real(a(:,vv));
%T=T./T(M);

g(ii+1)=max(real(eig(Delta_eps)));

ii=ii+1;

Tnew=T./T(M);

BGP_allocations;


 end

 BGP_allocations;
 
 %%Productivity (from ACR formulation)
 
 for i=1:M
    Y_L(i)=Q(i)*(alpha(i))^alpha(i)*(1-alpha(i))^(1-alpha(i))*((1/mbar)*Tnew(i)^0.25/pi_shareT(i,i)^0.25)^(alpha(i))*((1/mbar)*TNT(i)^0.25/pi_shareNT(i,i)^0.25).^(1-alpha(i));
   
 end
